using System.Data;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class VICC_LOG
    {
        public void SetUpNewRow(ref DataRow dwReturn, DataRow dwInput = null)
        {
            string time = "";
            Helpers.Helper.GetTime(ref date, ref time); 
            switch (app.company)
            {
                default:
                case "YGR":  
                    dwReturn["ICCSTARTTIME"]=date;
                    dwReturn["ICCENDTIME"] = time;
                    dwReturn["LOGKEY"] = "		";
                    dwReturn["CONTENTS"] = " "; 
                    break;
            } 
        }
        public void InsertICC_LOG(DataRow dwData, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "YGR":
                    or1.CommandText = "INSERT INTO ICC_LOG (ICCLOGID,ICCTABLENAME,ICCSTARTTIME,ICCENDTIME,LOGKEY,CONTENTS)"
                    + " VALUES (ICC_LOG_SEQ.NEXTVAL,:ICCTABLENAME:,:ICCSTARTTIME:,:ICCENDTIME:,:LOGKEY:,:CONTENTS:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public DataSet QLOG01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM ICC_LOG M "

                              + " WHERE ICCLOGID=:ICCLOGID:  ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QLOG02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM ICC_LOG M "  + " WHERE LOGKEY=:LOGKEY: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DLOG02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_LOG M " + " WHERE LOGKEY=:LOGKEY: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1); 
        }
        public void UpdateICC_LOG(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        { 
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "UPDATE ICC_LOG SET ICCLOGID=:ICCLOGID:,ICCTABLENAME=:ICCTABLENAME:,ICCSTARTTIME=:ICCSTARTTIME:,ICCENDTIME=:ICCENDTIME:,LOGKEY=:LOGKEY:,CONTENTS=:CONTENTS:"
                        + " WHERE ICCLOGID=:ICCLOGID:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }
        public void ULOG02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE ICC_LOG SET ICCLOGID=:ICCLOGID:,ICCTABLENAME=:ICCTABLENAME:,ICCSTARTTIME=:ICCSTARTTIME:,ICCENDTIME=:ICCENDTIME:,LOGKEY=:LOGKEY:,CONTENTS=:CONTENTS:"
                        + " WHERE LOGKEY=:LOGKEY:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
